package com.leetcode.根据数据结构分类.数组;

import java.util.Arrays;

/**
 * @author: xiaomi
 * @date: 2021/2/16
 * @description: 561. 数组拆分 I
 * https://leetcode-cn.com/problems/array-partition-i/
 */
public class A_561_数组拆分I {

    public static void main(String[] args) {

    }

    public int arrayPairSum(int[] nums) {
        //1.排序
        Arrays.sort(nums);
        //2.
        int res = 0;
        int len = nums.length;
        for (int i = 0; i < len; i+=2) {
            res += nums[i];
        }
        return res;
    }
}
